package adaptdesignmode;
import java.util.ArrayList;
import java.util.List;

public class BookShelf implements Aggregate <Book>{
    private ArrayList<Book> books=new ArrayList<>();
    public void appendBook(Book book){
        books.add(book);
    }
    public Book getBookAt(int index){
        return books.get(index);
    }
    public int getLenngth(){
        return books.size();
    }
    @Override//bookshelf履行契约  返回专属迭代器
    public MIterator <Book> iterator(){
        return new BookIShelfMIterator(this);
}}
